package com.gp.swagger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;

/**
 * @author: 弓成龙
 * @date : 2017年12月11日
 * @email : gcx909109@sina.cn
 * @description:
 */
@Configuration // 让Spring来加载该类配置
@EnableWebMvc // 非SpringBoot需启用
@EnableSwagger // 启用Swagger
public class Swagger2Config {
  
  private SpringSwaggerConfig springSwaggerConfig;
  
  @Autowired
  public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
      this.springSwaggerConfig = springSwaggerConfig;
  }

  @Bean
  public SwaggerSpringMvcPlugin customImplementation() {
      return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo()).includePatterns(".*?");
  }
  
  private ApiInfo apiInfo() {
    ApiInfo apiInfo = new ApiInfo(
        "艾乐贝贝商城API文档",
        "GraduationProject",
        "My Apps API terms of service", 
        null,
        null,
        "My Apps API License URL");
    return apiInfo;
  }

}
